package org.csu.mypetstorecmsapi.persistence;

import jakarta.transaction.Transactional;
import org.csu.mypetstorecmsapi.domain.SignOn;
import org.csu.mypetstorecmsapi.domain.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface SignOnDao extends JpaRepository<SignOn, Integer>
{
    @Transactional
    @Modifying
    @Query(value = "delete from signon where username =?1", nativeQuery = true)
    void deleteByUsername(String username);

    @Query(value = "select * from signon where username =?1 limit 1", nativeQuery = true)
    SignOn findByUsername(String username);
}
